var lcff_promptFill = {
    onLoad : function() {
        LockCrypt.loadPrefs();
        var matchData = window.arguments[0].inparams;
        var lstAccount = document.getElementById('lstAccount');
        for(var i=0;i<matchData.length;i++) {
            var thisMatch = matchData[i];
            var row = document.createElement('listitem');
            var cell = document.createElement('listcell');
            cell.setAttribute('label', decodeURIComponent(thisMatch.name));
            cell.setAttribute('value', i);
            row.appendChild(cell);
            cell = document.createElement('listcell');
            var username = "";
            if((typeof thisMatch.usernameID) == 'undefined') { // manually created form
                for(var j=0;j<thisMatch.fields.length;j++) {
                    if(thisMatch.fields[j].name.toLowerCase() == "username") {
                        username = decodeURIComponent(thisMatch.fields[j].value);
                    }
                }
            } else { // auto-saved or exported
                username = decodeURIComponent(thisMatch.username);
            }
            cell.setAttribute('label', username);
            cell.setAttribute('value', username);
            row.appendChild(cell);
            lstAccount.appendChild(row);
        }
        lstAccount.selectedIndex = 0;
        document.getElementById('chkOnlyEmpty').checked = LockCrypt.getOnlyEmpty();
    },
    fillFromAccount : function() {
        window.arguments[0].out = { 
            accountNum : document.getElementById('lstAccount').selectedIndex,
            onlyEmpty : document.getElementById('chkOnlyEmpty').checked,
        };
        close();
    },
    toggleFillOptions : function() {
        var fillDialog = document.getElementById("promptfill-window");
        var optionsBox = document.getElementById("lc-fill-options");
        var optsButton = fillDialog.getButton("disclosure");
        var width = fillDialog.width;
        if(optionsBox.collapsed) {
            optionsBox.setAttribute("collapsed","false");
            optsButton.label = LockCrypt.getString("options")+" «";
        } else {
            optionsBox.setAttribute("collapsed","true");
            optsButton.label = LockCrypt.getString("options")+" »";
        }
        fillDialog.sizeToContent(); // broken in FF3.0.1, but they might just fix it
    },
    cancelDialog : function() {
        close();
    }
};